var api="http://111.229.93.249:9888";
var apiurl="http://wpic.lslad.cn";
var apireg="http://lslad.cn";


		  (function($, doc) {
			  var userinfo = JSON.parse(localStorage.getItem('userinfo') || '{}');
		//2、选项卡点击事件
		 			mui('.mui-bar-tab').on('tap', 'a', function(e) {
						
						console.log("fdsaf")
		 				// 获取当前点击tab的href属性
		 				var targetTab = this.getAttribute('href');
						console.log(targetTab)
						location.href=targetTab;
						// mui.openWindow({url:targetTab});
		 			});
					var refreshhtml=doc.getElementById('refreshhtml');
					refreshhtml.addEventListener('tap', function() {
						location.reload();
					});
		 			var backlogin = doc.getElementById('backlogin');
		 			//3、退出系统时，默认还是加载初始化的页面，自定义事件，模拟点击“首页选项卡”
		 			backlogin.addEventListener('tap', function() {

						$.ajax(api+'/user/logout',{
							data:{
							},
							dataType:'json',//服务器返回json格式数据
							crossDomain:true,
							cache:true,
							type:'DELETE',//HTTP请求类型
							timeout:10000,//超时时间设置为10秒；data
							
							  beforeSend: function(request) {
								 
										   request.setRequestHeader("Content-Type",'application/json');
										   request.setRequestHeader("access_token", userinfo.access_token);
							  
										  },
							success:function(data){
								console.log(JSON.stringify(data))
								
								if(data.code==1){
									localStorage.setItem("userinfo","")
									$.toast("退出成功")
									
								}else{
									localStorage.setItem("userinfo","")
									$.toast(data.msg)
								}
								
								setTimeout(function () {
									// mui.openWindow({url:'login.html'});
									 // plus.runtime.restart();
									 
									location.href='login1.html'
									
								},20);
								 
							},
							error:function(xhr,type,errorThrown){
								localStorage.setItem("userinfo","")
								//异常处理；
								location.href='login1.html'
								$.toast("系统异常")
							}
						});
		 				
		 			});
						  }(mui, document));